﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace FieldDevice.UI
{
    public partial class AlarmLight : UserControl
    {
        public AlarmLight()
        {
            InitializeComponent();
        }

        [Category("SignalLight"), Description("报警灯指示，true为报警")]
        public bool Alarm
        {
            get;  set;
        }

        public Brush ALarmColor
        {
            get
            {
                if (this.Alarm == true)
                    return  Brushes.Red;
                else
                    return Brushes.Green;

            }
        }

        [Category("SignalLight"), Description("报警灯的直径")]
        public float Diameter
        {
            get 
            {
                if (this.Width < this.Height)
                    return this.Width;
                else
                    return this.Height;
            }        
        }

        private void Light_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphic = e.Graphics;
            graphic.FillEllipse(Brushes.Gray, 0, 0, Diameter, Diameter);
            graphic.FillEllipse(ALarmColor, 0.191f * Diameter, 0.191f * Diameter, 0.618f * Diameter, 0.618f * Diameter);
            graphic.Dispose();
        }
    }
}
